<template>
  <div class="app-container variables-wrapper">
    <div class="layout-content" id="layoutContent">
      <!-- <keep-alive v-if="$route.meta.keepAlive">
        <router-view></router-view>
      </keep-alive>
      <router-view v-else></router-view> -->
      <slot />
    </div>
    <div class="layout-footer variables-navbar-wrapper">
      <slot name="tabbar">
        <TabBar class="variables-navbar-wrapper" fixed :data="tabbars" @change="handleChange" />
      </slot>
    </div>
  </div>
</template>

<script>
import TabBar from '@/components/TabBar'
export default {
  name: 'AppLayout',
  data() {
    return {
      tabbars: [
        {
          title: 'Discovery',
          to: {
            name: 'Discovery'
          },
          icon: 'home-o'
        }
        // {
        //   title: 'Favorite',
        //   to: {
        //     name: 'Favorite'
        //   },
        //   icon: 'like-o'
        // }
        // {
        //   title: 'Me',
        //   to: {
        //     name: 'Me'
        //   },
        //   icon: 'user-o'
        // }
      ]
    }
  },
  components: {
    TabBar
  },

  mounted() {
    // this.$nextTick(() => {
    //   const dom = document.querySelector('#layoutContent')
    //   dom.addEventListener('scroll', this.handleScroll, {
    //     passive: false
    //   })
    // })
  },

  methods: {
    handleChange(v) {
      console.log('tab value:', v)
    },
    handleScroll(e) {
      console.log(e)
      console.log(e.target.scrollTop)
      const scrollTop = e.target.scrollTop
      if (scrollTop <= 0) {
        e.preventDefault()
        return
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  background-color: #fff;
  min-height: calc(100% - 50px);
  padding-bottom: 50px;
  box-sizing: border-box;
}

.layout-content {
}
</style>
